# Contributor: Raed Rizqie <raed.rizqie@gmail.com>

_realname=nbclient
pkgbase=mingw-w64-python-jupyter-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-python-jupyter-${_realname}
pkgver=0.8.0
pkgrel=2
pkgdesc='A client library for executing Jupyter notebooks (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url='https://github.com/jupyter/nbclient'
license=('spdx:BSD-3-Clause')
depends=(
    "${MINGW_PACKAGE_PREFIX}-python"
    "${MINGW_PACKAGE_PREFIX}-python-jupyter-nbformat"
    "${MINGW_PACKAGE_PREFIX}-python-jupyter_core"
    "${MINGW_PACKAGE_PREFIX}-python-jupyter_client"
    "${MINGW_PACKAGE_PREFIX}-python-traitlets")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-hatchling")
options=(!strip)
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('f9b179cd4b2d7bca965f900a2ebf0db4a12ebff2f36a711cb66861e4ae158e55')

prepare() {
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
